package estadistec.grafico;

import java.io.*;
import java.awt.*;
import javax.swing.plaf.*;
import javax.swing.plaf.metal.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;

/**
 * Clase que representa un estilo de colores para la interfaz grafica
 * En caso de implementar una nueva clase para el estilo de la aplicacion
 * esta es la debe de modificarse.
 * @author julatec
 */
public class EstiloAplicacion extends DefaultMetalTheme{

	private static final String THEME = "THEME";
	private static final String PRIMARY_1 = "PRIMARY_1";
	private static final String PRIMARY_2 = "PRIMARY_2";
	private static final String PRIMARY_3 = "PRIMARY_3";
	private static final String SECONDARY_1 = "SECONDARY_1";
	private static final String SECONDARY_2 = "SECONDARY_2";
	private static final String SECONDARY_3 = "SECONDARY_3";
	private static final String WHITE = "WHITE";
	private static final String BLACK = "BLACK";
	private static final String NAME = "name";
	private static final String VALUE = "value";
	

	/*
	 * Set de Colores que se utilizaran en la interfaz.
	 */
	private ColorUIResource primary1 = new ColorUIResource(100, 200, 100);
	private ColorUIResource primary2 = new ColorUIResource(50, 200, 100);
	private ColorUIResource primary3 = new ColorUIResource(250, 250, 250);

	private ColorUIResource secondary1 = new ColorUIResource(150, 200, 150);
	private ColorUIResource secondary2 = new ColorUIResource(150, 200, 100);
	private ColorUIResource secondary3 = new ColorUIResource(200, 200, 150);

	private ColorUIResource white = new ColorUIResource(255, 255, 255);
	private ColorUIResource black = new ColorUIResource(0, 0, 0);

	private String name;

	public EstiloAplicacion() {
		name = "Tema por defecto";
	}

	public EstiloAplicacion(File colorSet) throws ParserConfigurationException,
			org.xml.sax.SAXException, IOException {
		Document document = Utilidades.crearDOM(colorSet);

		name = document.getElementById(THEME).getAttribute(NAME);

		primary1 = obtenerColor(document.getElementById(PRIMARY_1)
				.getAttribute(VALUE));
		primary2 = obtenerColor(document.getElementById(PRIMARY_2)
				.getAttribute(VALUE));
		primary3 = obtenerColor(document.getElementById(PRIMARY_3)
				.getAttribute(VALUE));

		secondary1 = obtenerColor(document.getElementById(SECONDARY_1)
				.getAttribute(VALUE));
		secondary2 = obtenerColor(document.getElementById(SECONDARY_2)
				.getAttribute(VALUE));
		secondary3 = obtenerColor(document.getElementById(SECONDARY_3)
				.getAttribute(VALUE));

		white = obtenerColor(document.getElementById(WHITE).getAttribute(VALUE));
		black = obtenerColor(document.getElementById(BLACK).getAttribute(VALUE));

	}

	private ColorUIResource obtenerColor(String codigoHexadecimal) {
		return new ColorUIResource(Color.decode(codigoHexadecimal));
	}

	public String getName() {
		return name;
	}

	protected ColorUIResource getPrimary1() {
		return primary1;
	}

	protected ColorUIResource getPrimary2() {
		return primary2;
	}

	protected ColorUIResource getPrimary3() {
		return primary3;
	}

	protected ColorUIResource getSecondary1() {
		return secondary1;
	}

	protected ColorUIResource getSecondary2() {
		return secondary2;
	}

	protected ColorUIResource getSecondary3() {
		return secondary3;
	}

	protected ColorUIResource getBlack() {
		return black;
	}

	protected ColorUIResource getWhite() {
		return white;
	}

}